import { queryUrlParams } from '@/utils/index'
import request from '@/utils/request'

// 开处方
export function open(data) {
  return request({
    url: '/api/recipel/open',
    method: 'post',
    data
  })
}
// 查询诊断
export function getDiagnosis(data) {
  const datas = {
    page: 0,
    size: 400,
    sort: ['tcm_diseases_id'],
    diseasesName: data,
    pinyinCode: data
  }
  const param = queryUrlParams(datas)
  const url = '/tcmdiseases/list?' + param
  return request({
    url: url,
    method: 'get'
  })
}

// 查询领用人列表，暂时查询当前系统用户
export function getNewCollectUses() {
  return request({
    url: '/api/users/getList',
    method: 'post'
  })
}

// 删除处方
export function delPrestion(data) {
  return request({
    url: '/api/recipel/deleteInfo',
    method: 'post',
    params: data
  })
}
// 作废处方
export function removeInfo(data) {
  return request({
    url: '/api/recipel/removeInfo',
    method: 'post',
    params: data
  })
}
// 删除药品
export function delDrug(data) {
  return request({
    url: '/api/recipel/deleteInfoDrug',
    method: 'post',
    params: data
  })
}
export function getUseFormList(query) {
  const url = '/use/getList?status=0&useAllClinic=' + query.useAllClinic
  return request({
    url: url,
    method: 'post'
  })
}

// 查询药品
export function findDrug(data) {
  return request({
    url: '/api/recipel/findDrug',
    method: 'post',
    data
  })
}

// 完成处方
export function saveOrder(data) {
  return request({
    url: '/api/recipel/saveOrder',
    method: 'post',
    data
  })
}

// 查找附加费用
export function findForAdditional(data) {
  return request({
    url: '/api/recipel/findForAdditional',
    method: 'post',
    data
  })
}

// 问诊详情
export function detail(data) {
  return request({
    url: '/api/recipel/detail',
    method: 'post',
    data
  })
}
// 处方详情
export function getDetails(data) {
  return request({
    url: '/api/recipel/getDetail?id=' + data,
    method: 'get',
    data
  })
}
// 退款
export function orderRefundOrder(data) {
  return request({
    url: '/api/recipel/refundOrder',
    method: 'post',
    data
  })
}

// 查询待审方数
export function waitCheck(prescriptionType) {
  return request({
    url: 'api/recipel/waitCheck?prescriptionType=' + prescriptionType,
    method: 'get'
  })
}

// 查询待审方数
export function waitRefund(prescriptionType) {
  return request({
    url: 'api/recipel/waitRefund?prescriptionType=' + prescriptionType,
    method: 'get'
  })
}

export default { open, findDrug, saveOrder, findForAdditional, detail }
